package com.oms.module.admin.domain.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

/**
 * @Author zhanghailong QQ38592077
 * @Description TODO
 * @Date 2020/6/8 18:00
 */
@TableName(value = "oms_admin")
@ToString(callSuper = true)
@Data
public class AdminEntity implements UserDetails {
    /**
     * 用户名
     */
    private String username;
    /**
     * 密码
     */
    private String password;
    /**
     * 账号是否没过期
     */
    private boolean accountNonExpired;
    /**
     * 账号是否没锁定
     */
    private boolean accountNonLocked;
    /**
     * 密码是否没过期
     */
    private boolean credentialsNonExpired;
    /**
     * 禁止登陆
     */
    private boolean enabled;
    /**
     * id
     */
    private Long id;
    /**
     * 名字
     */
    private String name;
    /**
     * 手机号
     */
    private String phone;
    /**
     * 电话
     */
    private String telephone;
    /**
     * 地址
     */
    private String address;

    private String userface;
    /**
     * 备注
     */
    private String remark;
//    private List<Role> roles;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {

        List<SimpleGrantedAuthority> list = new ArrayList<>();
        list.add(new SimpleGrantedAuthority("ROLE_admin"));
        return list;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return accountNonExpired;
    }

    @Override
    public boolean isAccountNonLocked() {
        return accountNonLocked;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return credentialsNonExpired;
    }

    @Override
    public boolean isEnabled() {
        return enabled;
    }
}
